(() => {
    console.log('hello world aaaaa')

    // 数组
    let arr1: number[] = [1, 3, 4, 5]

    let arr2: string[] = ['a', 'b']

    let arr3: Array<number> = [123, 344, 555]
    arr3.push(456)

    for (const key in arr3) {
        if (Object.prototype.hasOwnProperty.call(arr3, key)) {
            const element = arr3[key];
            console.log(element)
        }
    }

    // 元祖
    let tu1: [string, number, boolean] = ['yejing', 35, true]
    console.log(tu1)

    console.log(tu1[0])
    console.log(tu1[1])
    console.log(tu1[2])

    // 枚举
    enum Color {
        red = 10, yellow = 100, blue = 1000, green = 10000
    }

    console.log(Color.red)
    console.log(Color.yellow)
    console.log(Color.blue)
    console.log(Color.green)

    console.log(Color[100])

    // 字符串
    let name: string = 'yejing'
    let wel: string = `hello ${name}`
    console.log(123, wel);

    // any 类型，就是不知道是什么类型，什么值都可以
    let a1: any = 'hello world'
    console.log(a1)
    a1 = 4;
    console.log(a1)

    // unknown 类型，也是不知道是什么类型，什么值都可以
    let b1: unknown = 10;
    console.log(111, b1);
    b1 = 'hello world';
    console.log(111, b1);


    function showMsg(): void {

        console.log("hello world")
    }

    function foo(): string {

        return '年少不知富婆好，错把少妇当个宝'
    }

    console.log(foo())


    // 对象类型
    function getObject(obj: object): object {

        console.log(obj)

        return {
            name: '卡卡西',
            age: 27
        }
    }

    console.log(getObject({ name: 'aaa', age: 45 }))


    // 类型断言
    function getString(str: string | number): number {

        // (<string>str)
        if ((<string>str).length) {
            return (<string>str).length
        } else {
            return str.toString().length
        }
    }

    console.log(getString('abc'))
    console.log(getString(12345))

    // 解构

    let input:[string,number] = ['hello',34];

    function test(input:[string,number]){
        let [a,b] = input;

        console.log(1234,a);
        console.log(1234,b);
    }

    test(input);

})()